/**
 * @description ...
 * @author cx
 * @date 2024.08.12 14:19
 */


package com.cx.controller;


import com.cx.service.serviceimp.AccountsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TransactionController {
    @Autowired
    private AccountsServiceImpl accountsService;


    @PostMapping("/transfer")
    public String transfer(@RequestParam Integer fromAccountId, @RequestParam Integer toAccountId, @RequestParam Double amount) {
        try {
            accountsService.transfer(fromAccountId, toAccountId, amount);
            return "Transfer successful";
        } catch (Exception e) {
            return "Transfer failed: " + e.getMessage();
        }
    }
}
